# a = 'sadasd'+ \
#     'asdasdasd'+ \
#     'dasdasd'
# print(a)

# disaster = True
# if disaster :
#     print('woe!')
# else :
#     print('whee!')

# furry = True
# small = True
# if furry :
#     if small :
#         print('it\'s  cat ')
#     else:
#         print('it\'s bear ')
# else:
#     if small :
#         print('it\'s  shink ')
#     else:
#         print('it\'s a human .Or  a hairless bear. ')

# color = 'puce'
# if color == 'red':
#     print("it's a tomato")
# elif color == 'green':
#     print("it's a green peper")
# elif color == 'bee purple':
#     print("i don't know what it is ")
# else :
#     print("i've never heard of the color ",color)

# count = 1
# while count<=5 :
#     print(count)
#     count += 1

# while True :
#     stuff = input('string to capitalize [type q to quit]:')
#     if stuff == 'q' :
#         break
#     print(stuff.capitalize())


# while True :
#     value = input('please :')
#     if value == 'q' :
#         break
#     number = int(value)
#     if number % 2 == 0 :
#         continue
#     print(number,'squared is ',number*number)

# numbers = [1,4,5]
# position = 0
# while position < len(numbers) :
#     number = numbers[position]
#     if number%2 == 0:
#         print('found even number',number)
#         break
#     position += 1
# else :
#     print('no even number found')

# rabbits = ['Flopsy','Monsy','Cottontail','Peter']
# current = 0
# while current < len(rabbits) :
#     print(rabbits[current])
#     current += 1

# for rabbit in rabbits :
#     print(rabbit)
#
# word = 'cat'
# for letter in word :
#     print(letter)

# accusation = {
#     'room' : 'ballroom',
#     'weapon' : 'lead pipe',
#     'person' : 'cpl.mustard'
# }
#
# for card,value in accusation.items() :
#     print(card,value)
#
# for value in accusation.values() :
#     print(value)
#
# for card in accusation:
#     print(card)

# days = ['Monday','Tuesday','Wednesday']
# fruits = ['banana', 'orange', 'peach']
# drinks = ['coffee', 'tea', 'beer']
# desserts = ['tiramisu', 'ice cream', 'pie', 'pudding']
#
# for day,fruit,drink,dessert in zip(days,fruits,drinks,desserts):
#     print(day, ": drink", drink, "- eat", fruit, "- enjoy", dessert)

# english = 'Monday', 'Tuesday', 'Wednesday'
# french = 'Lundi', 'Mardi', 'Mercredi'
#
# print(list(zip(english,french)))
# print(dict(zip(english,french)))

# for x in range(2,-1,-1):
#     print(x)
#
# print(list(range(2,-1,-1)))

# number_list = []
#
# number_list.append(1)
# number_list.append(2)
# number_list.append(3)
# number_list.append(4)
# number_list.append(5)
#
# print(number_list)

# number_list = []
# for x in range(1,6):
#     number_list.append(x)
# print(number_list)

# number_list = [number for number in range(1,6)]
# print(number_list)
#
# number_list = [number-1 for number in range(1,6)]
# print(number_list)

# a_list = [number for number in range(1,6) if number %2 == 1]
#
# print(a_list)

# rows = range(1,4)
# cols = range(1,3)
# for row in rows :
#     for col in cols :
#         print(row,col)

# rows = range(1,4)
# cols = range(1,3)
# cells = [(row,col) for row in rows for col in cols]
# for row,col in cells:
#     print(row,col)

word = 'letters'
# letter_counts = {
#     letter : word.count(letter)  for letter in word
# }
#
# print(letter_counts)
# letter_counts = {letter:word.count(letter) for letter in set(word)}
# print(letter_counts)
#
#
#

# thing = None
# if thing is None :
#     print("it's none")
# elif thing:
#     print("it's true")
# else:
#     print("it's False")

# def menu(wine,entree,dessert):
#     return {'wine': wine, 'entree': entree, 'dessert': dessert}
# print(menu('chardonnay', 'chicken', 'cake'))
#
# print(menu(entree='beef', dessert='bagel', wine='bordeaux'))

# def buggy(arg,result=[]) :
#     result.append(arg)
#     print(result)
# buggy('a')
# buggy('b')


# def  works(arg) :
#     result = []
#     result.append(arg)
#     return result
# print(works('a'))
# print(works('b'))

# def print_args(*args):
#     print('positionam argument tuple:',args)
# print_args(3,2,1)

# def print_more(required1, required2, *args):
#     print('need this one :',required1)
#     print('need this one too:', required2)
#     print('all the rest :',args)
#
# print_more('cap','gloves','scarf','monocle','mustache wax')

# def print_kwargs(**kwargs) :
#     print('keyword arguments:',kwargs)
#
# print_kwargs(wine='merlot',entree='mutton',dessert='macaroon')
#
#
# print(echo.__doc__)

# def answer() :
#     print(42)
#
# def run_something(func):
#     func()
#
# run_something(answer)

# def add_args(arg1,arg2):
#     print(arg1+arg2)
#
# print(type(add_args))

# def sum_args(*args):
#     return sum(args)
# def run_with_positional_args(func,*args):
#     return func(*args)
#
# print(run_with_positional_args(sum_args,12,3,4,5,4))

# def outer(a,b) :
#     def inner(c,d):
#         return c+d
#     return inner(a,b)
# print(outer(4,7))

# def knights2(saying):
#     def inner2():
#         return "we are the kngiths who say :'%s'" % saying
#     return inner2


# def edit_story(words,func):
#
#     for word in words :
#         print(func(word))
#
# stairs = ['thud','meow','thud','hiss']
#
# def enliven(word) :
#     return  word.capitalize()+'!'
#
# edit_story(stairs,enliven)

# edit_story(stairs,lambda word : word.capitalize()+"!")


# print(sum(range(1,101)))

# def document_it(func) :
#     def new_function(*args,**kwargs):
#         print('Running function:', func.__name__)
#         print('Positional arguments:', args)
#         print('Keyword arguments:', kwargs)
#         result = func(*args, **kwargs)
#         print('Result:', result)
#         return result
#     return new_function
# def add_ints(a, b):
#     return a + b
# print(add_ints(3, 5))
# cooler_add_ints = document_it(add_ints)
# cooler_add_ints(3, 5)

# @decorator_name :
#     @document_it:
#         def add_init(a,b):
#             return a+b

# @document_it
# def add_ints(a,b):
#     return a+b
# print(add_ints(3,5))

# def squre_it(func):
#     def new_function(*args,**rwargs):
#         result = func(*args,**rwargs)
#         return result
#     return  new_function
# @document_it
# @squre_it
# def add_ints(a,b):
#     return a+b
# add_ints(2,3)

# animal = 'fruitbat'
# def print_global():
#     print('inside print_global:',animal)
# print(print_global())

# animal = 'fruitbat'
# def change_local():
#     animal = 'wombat'
#     print('locals',locals())
#
# print(animal)

# change_local()
# print('globals:',globals())

# def amazing():
#     '''This is the amazing function.
#     Want to see it again?'''
#     print('This function is named:', amazing.__name__)
#     print('And its docstring is:', amazing.__doc__)
# amazing()

# short_list = [1,2,3]
# position = 5
# try:
#     short_list[position]
# except:
#     print('need a position between 0 and ',len(short_list)-1 ,'but got',position)

# short_list = [1,2,3]
# while True:
#     value = input('Position [q to quit]?')
#     if value == 'q':
#         break
#     try:
#         position = int(value)
#         print(short_list[position])
#     except IndexError as err:
#         print('Bad index :',position)
#     except Exception as other:
#         print('something else broke :',other)

# a = 0.8*0.9
# print(a)

# 1
# while True:
#     gaess_name = input('shuru:')
#     gaess_name = int(gaess_name)
#     if gaess_name < 7 :
#         print('too low')
#         continue
#     elif gaess_name > 7 :
#         print('too height')
#         continue
#     else :
#         print('just right')
#         continue

#2
# guess_me = 7
# start = 1
#
# while True :
#     if start < guess_me :
#         print("too low")
#     elif start == guess_me :
#         print("found it")
#         break
#     elif  start > guess_me :
#         print("ops")
#         break
#     start += 1

#3
# for value in [3,2,10]:
#     print(value)

#4
# even = [number for number in range(10) if number %2 == 0 ]
# print(even)

# 5
# squares = {key:key*key for key in range(10)}
# print(squares)
#使用 合     合 odd，   0~9   range(10) 的 数。

# odd = {number for number in range(10) if number %2 == 1}
# print(odd)

#(7)使用 成     字  'Got ' 0~9 的一个 数，使用for   行  。

# for thing in ('Got %s' % number for number in range(10)):
#     print(thing)

# def good() :
#     return ['Harry', 'Ron', 'Hermione']
#
# print(good())


# def get_odds():
#     odds = [number for number in range(9) if number % 2 == 1 ]
#     print(odds)

# def get_odds():
#     for number in range(1,10,2):
#         yield number
#
# for count,number in enumerate(get_odds(),1):
#     if count == 3 :
#         print("the number :",number)
#         break
#

# def test(func):
#     def new_func(*args,**kwargs):
#        print('start')
#        result = func(*args,**kwargs)
#        print('end')
#        return result
#     return new_func
# @test
# def greeting():
#     print('greetings,earthling')
# greeting()

# class OopsException(Exception):
#     pass
# #
# try :
#     raise OopsException()
# except OopsException as oop:
#     print('Caught an oops',oop)

# titles = ['Creature','Crewel Fate']
# plots = ['A nun turns into a monster', 'A haunted yarn shop']
# movies = dict(zip(titles,plots))
#
# print(movies)



























